from typing import Dict

from sqlalchemy import ForeignKey, String
from sqlalchemy.dialects.postgresql import JSONB, TIMESTAMP, UUID
from sqlalchemy.orm import Mapped, mapped_column

from .base_model import OrmBase
from .document import Document


class Page(OrmBase):
    __tablename__ = 'page'

    uuid: Mapped[str] = mapped_column(String(70), primary_key=True)
    document_uuid: Mapped[str] = mapped_column(
        UUID(as_uuid=True),
        ForeignKey(Document.uuid),
    )
    entities: Mapped[Dict] = mapped_column(JSONB)

    def __repr__(self) -> str:
        return f'Page(uuid={self.uuid!r}, document_uuid={self.document_uuid!r}, entities={self.entities!r})'
